<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>4.$watch的使用</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <h2>当前的n值是：{{n}}</h2>
      <button @click="n+=1">点我n+1</button>
    </div>

    <script type="text/javascript">
      let vm = new Vue({
        el:'#demo',
        data:{
          n:1
        },
      })

      vm.$watch('n',function(value){
        console.log(value)
      })
    </script>
  </body>
</html>